﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WaterFallPic.Controllers
{
    public class GetPresult
    {
     
        public Photos Photos { get; set; }
    }

    public class Photos
    {
        public int Page { get; set; }
        public int Pages { get; set; }
        public IList<Photo> Photo { get; set; }
    }

    public class Photo
    {
        public string Title { get; set; }
        public string Src { get; set; }
    }

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }


        public JsonResult GetPictures(int pageIndex)
        {
            var result = new GetPresult();
            var p = new Photo()
                        {
                            Title = "ttt",
                            Src = "http://farm9.static.flickr.com/8106/8526717463_2af35ee8a9_m.jpg"
                        };

            var photos = new Photos();
            photos.Photo = new List<Photo>();
            for (var i = 0; i < 20;i ++ )
            {
                photos.Photo.Add(p);
            }
            photos.Pages = 20;
            photos.Page = pageIndex;
            result.Photos = photos;

            return Json(result, JsonRequestBehavior.AllowGet);
        }
    }
}
